package com.mvu.banana.common.widget;

import com.google.gwt.core.client.GWT;
import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.uibinder.client.*;
import com.google.gwt.user.client.ui.Anchor;
import com.google.gwt.user.client.ui.Composite;
import com.google.gwt.user.client.ui.FlowPanel;
import com.google.gwt.user.client.ui.HTMLPanel;

/**
 * Created by IntelliJ IDEA.
 * User: mvu
 * Date: 4/20/11
 * Time: 4:36 PM
 * To change this template use File | Settings | File Templates.
 */
public class BottomPanel extends Composite{
  @UiTemplate("BottomPanel.ui.xml")
  interface BottomPanelUiBinder extends UiBinder<HTMLPanel, BottomPanel> { }
  private static BottomPanelUiBinder panelBinder = GWT.create(BottomPanelUiBinder.class);

  @UiTemplate("CreditsTile.ui.xml")
  interface CreditsTileUiBinder extends UiBinder<FlowPanel, BottomPanel> { }
  private static CreditsTileUiBinder tileBinder = GWT.create(CreditsTileUiBinder.class);

  @UiField Anchor aboutLink;

  @UiConstructor
  public BottomPanel(boolean isTile) {
    if(isTile){
      initWidget(tileBinder.createAndBindUi(this));
    }else{
      initWidget(panelBinder.createAndBindUi(this));
    }
  }

  @UiHandler("aboutLink")
  void onAboutClicked(ClickEvent event) {
    // When the 'About' item is selected, show the AboutDialog.
    // Note that showing a dialog box does not block -- execution continues
    // normally, and the dialog fires an event when it is closed.
    AboutDialog dlg = new AboutDialog();
    dlg.show();
  }
}